﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace JMT.Data
{
    public class JConstString
    {
        public const string TSolution = "solution";
        public const string TPackage = "package";
        public const string TDiagram = "diagram";
        public const string TClass = "class";
        public const string TInterface = "interface";
        public const string TProperty = "property";
        public const string TMethod = "method";
        public const string TElement = "element";
        //public const string TRelation = "relation";
        //public const string TRefer = "refer";
        public const string TGeneralization = "generalization";
        public const string TAggregation = "aggregation";
        public const string TAssociation = "association";
        public const string TComposition = "composition";

        public static string GetType<T>() where T : JModel
        {
            if (typeof(T) == typeof(JSolution))
            {
                return TSolution;
            }
            else if (typeof(T) == typeof(JPackage))
            {
                return TPackage;
            }
            else if (typeof(T) == typeof(JDiagram))
            {
                return TDiagram;
            }
            else if (typeof(T) == typeof(JInterface))
            {
                return TInterface;
            }
            else if (typeof(T) == typeof(JClass))
            {
                return TClass;
            }
            else if (typeof(T) == typeof(JMethod))
            {
                return TMethod;
            }
            else if (typeof(T) == typeof(JProperty))
            {
                return TProperty;
            }
            else if (typeof(T) == typeof(JElement))
            {
                return TElement;
            }
            else if (typeof(T) == typeof(JGeneralization))
            {
                return TGeneralization;
            }
            else if (typeof(T) == typeof(JAssociation))
            {
                return TAssociation;
            }
            else if (typeof(T) == typeof(JAggregation))
            {
                return TAggregation;
            }
            else if (typeof(T) == typeof(JComposition))
            {
                return TComposition;
            }
            return string.Empty;
        }

        public static string GetType(Type type)
        {
            string modelType = null;
            if (type == typeof(JSolution))
            {
                modelType = JConstString.TSolution;
            }
            else if (type == typeof(JPackage))
            {
                modelType = JConstString.TPackage;
            }
            else if (type == typeof(JDiagram))
            {
                modelType = JConstString.TDiagram;
            }
            else if (type == typeof(JInterface))
            {
                modelType = JConstString.TInterface;
            }
            else if (type == typeof(JClass))
            {
                modelType = JConstString.TClass;
            }
            else if (type == typeof(JMethod))
            {
                modelType = JConstString.TMethod;
            }
            else if (type == typeof(JProperty))
            {
                modelType = JConstString.TProperty;
            }
            else if (type == typeof(JElement))
            {
                modelType = JConstString.TElement;
            }
            else if (type == typeof(JGeneralization))
            {
                modelType = JConstString.TGeneralization;
            }
            else if (type == typeof(JAggregation))
            {
                modelType = JConstString.TAggregation;
            }
            else if (type == typeof(JAssociation))
            {
                modelType = JConstString.TAssociation;
            }
            else if (type == typeof(JComposition))
            {
                modelType = JConstString.TComposition;
            }
            return modelType;
        }

        public static Type GetModelType(string typeName)
        {
            Type modelType = null;
            if (typeName == JConstString.TSolution)
            {
                modelType = typeof(JSolution);
            }
            else if (typeName == JConstString.TPackage)
            {
                modelType = typeof(JPackage);
            }
            else if (typeName == JConstString.TDiagram)
            {
                modelType = typeof(JDiagram);
            }
            else if (typeName == JConstString.TInterface)
            {
                modelType = typeof(JInterface);
            }
            else if (typeName == JConstString.TClass)
            {
                modelType = typeof(JClass);
            }
            else if (typeName == JConstString.TMethod)
            {
                modelType = typeof(JMethod);
            }
            else if (typeName == JConstString.TProperty)
            {
                modelType = typeof(JProperty);
            }
            else if (typeName == JConstString.TElement)
            {
                modelType = typeof(JElement);
            }
            else if (typeName == JConstString.TGeneralization)
            {
                modelType = typeof(JGeneralization);
            }
            else if (typeName == JConstString.TAggregation)
            {
                modelType = typeof(JAggregation);
            }
            else if (typeName == JConstString.TAssociation)
            {
                modelType = typeof(JAssociation);
            }
            else if (typeName == JConstString.TComposition)
            {
                modelType = typeof(JComposition);
            }
            return modelType;
        }
    }
}
